class CategoryController < ApplicationController

	caches_page :index
	caches_page :show

	layout "home"
	before_filter :set_bottomlinks
	before_filter :set_toplinks
	before_filter :set_about
	before_filter :set_contact_us
	before_filter :set_our_services
	before_filter :set_menu
	before_filter :set_current_top_category

	def index
		logger.debug "========================= LANGUAGE : #{session['lang']}"
	end

	def show	
 		@gauche = Article.ez_find(:all, :include => [:category,:tags,:taggings], :order => "published_at") do |article, category, tag, tagging|
      category.permalink == @category.permalink 
      article.published == 1
			tag.name == 'gauche'
    end	

		@droite = Article.ez_find(:all, :include => [:category,:tags,:taggings], :order => "published_at") do |article, category, tag, tagging|
      category.permalink == @category.permalink 
      article.published == 1
			tag.name == 'droite'
    end	

		if @droite.empty?
			parent_category = @category.parent
			unless parent_category.nil?
				@droite = Article.ez_find(:all, :include => [:category,:tags,:taggings], :order => "published_at") do |article, category, tag, tagging|
		      category.permalink == parent_category.permalink
		      article.published == 1
					tag.name == 'droite'
		    end
			end
		end

		if @gauche.empty?
			@gauche = Article.ez_find(:all, :include => :category, :order => "published_at") do |article, category|
      	category.permalink == @category.permalink 
      	article.published == 1
    	end		
			@gauche = @gauche - @droite
		end
		
		unless @category.nil?
			@page_title << " - #{@category.name}"
		end
	end
		

end
